package com.msb.dp.singleton;

/**
 * @Auther: Huanyu Lee
 * @Date: 2022/3/2  22:40
 * @Description: 改进版的懒汉式
 * 通过synchronized解决了线程不安全问题
 * 但也带来了效率的下降
 */
public class Mgr03 {
    private static Mgr03 INSTACNE;
    private Mgr03(){}
    public static synchronized Mgr03 getInstance(){
        if (INSTACNE == null) {
            try {
                Thread.sleep(1);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            INSTACNE = new Mgr03();
        }
        return INSTACNE;
    }
}
